<!doctype html>
<html>
<head>
<meta charset="utf-8">
<link rel="stylesheet" href="__TMPL__Public/assets/book_static/css/base.css" />
<link rel="stylesheet" href="__TMPL__Public/assets/book_static/css/info-mgt.css" />
<link rel="stylesheet" href="__TMPL__Public/assets/book_static/css/WdatePicker.css" />
<link rel="stylesheet" href="__TMPL__Public/assets/layui/css/layui.css">
<link rel="stylesheet" href="__TMPL__Public/assets/book_static/css/pager.css">
<script type="text/javascript" src="__TMPL__Public/assets/book_static/js/jquery.js"></script>
<script type="text/javascript" src="__TMPL__Public/assets/layui/layui.js"></script>
<title>图书库存管理系统</title>
</head>

<body>
<div class="title"><h2>图书出库方案打印</h2></div>
<div class="query">
	<div class="query-conditions ue-clear">
	
	
        <div class="conditions staff ue-clear" style="width:890px;">
			<form id="searchform" target="_self" method="GET" action="index.php">
				<input type="hidden" name="m" value="index">
				<input type="hidden" name="a" value="printlist">
				<div class="conditions time ue-clear" style="line-height:38px;width:430px;">
					<label>出库时间：</label>
					<div class="time-select">
						<input style="width: 145px;"  type="text" id="starttime"  name="starttime"  value="{$data.starttime}" onfocus="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm'})" placeholder="开始时间" />
						<i class="icon"  style="top:4px;"></i>
					</div>
					<span class="line">-</span>
					<div class="time-select">
						<input style="width: 145px;" type="text"  id="endtime" name="endtime" value="{$data.endtime}"  onfocus="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm'})" placeholder="结束时间" />
						<i class="icon"  style="top:4px;"></i>
					</div>
				</div>
				<select name="isprint" style="line-height:38px;height:38px;">
					<option value="0" <if condition="$data.isprint eq ''">selected=selected</if>>全部</option>
					<option value="2" <if condition="$data.isprint eq '2'">selected=selected</if>>未打印</option>
					<option value="3" <if condition="$data.isprint eq '3'">selected=selected</if>>已打印</option>
				</select>
				<button type="button" class="layui-btn layui-btn-normal" id="test12" style="margin-top: -5px;">查询</button>
			</form>
		</div>
		
		
		
		
        <div class="conditions staff ue-clear" style="float:right;width:100px;">
			<button type="button" class="layui-btn layui-btn-danger" id="printlist"><i class="layui-icon">&#xe61e;</i>打印出库单</button>
		</div>
    </div>
</div>

<div class="table-box">
	<table>
    	<thead>
        	<tr>
            	<th class="num">序号</th>
            	<th class="num"><a href="{:U('index/printlist')}&orderby=isprint<if condition="$data.orderby eq 'isprint'">&orderway={$data.orderway}</if>">状态</a></th>
                <th class="name">ISBN</th>
                <th class="node">书名</th>
				<th class="process"><a href="{:U('index/printlist')}&isprint={$data.isprint}&orderby=location<if condition="$data.orderby eq 'location'">&orderway={$data.orderway}</if>">位置</a></th>
                <th class="name"><a href="{:U('index/printlist')}&isprint={$data.isprint}&orderby=booknum<if condition="$data.orderby eq 'booknum'">&orderway={$data.orderway}</if>">数量<span>(本)</span></a></th>
                <th class="time"><a href="{:U('index/printlist')}&isprint={$data.isprint}&orderby=price<if condition="$data.orderby eq 'price'">&orderway={$data.orderway}</if>">价格</a></th>
                <th class="time">出库时间</th>
            </tr>
        </thead>
        <tbody>
			<foreach name="data.list" item="vo" key="k">
        	<tr class="{$vo.id}">
            	<td class="num">{$vo.id}</td>
            	<td class="num">
					<?php
						if($vo['isprint']==""){
							echo "<font color=red>尚未打印</font>";
						}else{
							echo "已打印";
						}
					?>
				</td>
                <td class="name isbn" vi="{$vo.bookname}">{$vo.isbn}</td>
                <td class="node bookname" style="width:300px">
				<if condition="$vo.bookname neq ''">
				{$vo.bookname}
				<else/>
				--
				</if>
				</td>
                <td class="process">
				<?php
				if($vo['location']=="缺货"){
					echo "<font color=red>缺货</font>";
				}else{
					echo $vo['location'];
				}
				?>
				</td>
                <td class="name">{$vo.booknum}</td>
                <td class="time price">{$vo.price}</td>
                <td class="time">{$vo.outtime}</td>
            </tr>
			</foreach>
        </tbody>
    </table>
</div>

<div class="pxofy">合计&nbsp;{$data.count}&nbsp;本书
</div>
<div class="page-control ue-clear"></div>


</body>
<script type="text/javascript" src="__TMPL__Public/assets/book_static/js/jquery.page.js"></script>
<script type="text/javascript" src="__TMPL__Public/assets/book_static/js/common.js"></script>
<script type="text/javascript" src="__TMPL__Public/assets/book_static/js/WdatePicker.js"></script>
<script type="text/javascript" src="__TMPL__Public/assets/book_static/js/jquery.pagination.js"></script>

<script type="text/javascript">
$("#test12").click(function(){
	$("#searchform").submit();
})

$(".select-title").on("click",function(){
	$(".select-list").hide();
	$(this).siblings($(".select-list")).show();
	return false;
})
$(".select-list").on("click","li",function(){
	var txt = $(this).text();
	$(this).parent($(".select-list")).siblings($(".select-title")).find("span").text(txt);
})


//select 分页器
$("#pageselect").change(function(){
	var index = layer.load(0, {shade: 0.1}); //0代表加载的风格，支持0-2
	var pageurl = '{$data.pageurl}';
	var page = $(this).val();
	window.location.href=pageurl+"&page="+page; 
})

$("tbody").find("tr:odd").css("backgroundColor","#eff6fa");

layui.use('upload', function(){
	var $ = layui.jquery
	,upload = layui.upload;
	upload.render({
		elem: '#test8'
		,url: "{:U('index/up')}"
		,accept: 'file'
		,auto: false
		//,multiple: true
		,bindAction: '#test9'
		,before: function(res){
			layer.load(3, {shade: 0.1}); //上传loading
		}
		,done: function(res){
			if(res.state=="fail"){
				layer.closeAll('loading');
				layer.msg('导入失败，'+res.message, {time: 5000, icon:5,shade: 0.7});
			}else{
				layer.closeAll('loading');
				layer.msg('导入成功！', {time: 5000, icon:6,shade: 0.7});
				window.location.reload();
			}
		},error: function(index, upload){
			layer.closeAll('loading');
		}
	});
});

$(document).ready(function(){
		var updatetime = 0;
		$(".isbn").each(function(i){
			var isbn = $(this).html();
			var bookname = $(this).attr("vi");
			if(isbn==''){
				return true;
			}
			if(bookname!=''){
				$("#myloading").html("");
				return true;
			}
			thisclass = "{$data['list'][0]['id']}";
			var url = "{:U('index/updateisbninfo')}&isbn="+isbn;
			$.getJSON(url,function(result){
				if(result.status==0){
					thisclass--;
					return false;
				}else{
					var imgstr = result.title;
					if(typeof(result.title)!="undefined"){
						$("."+thisclass).find("td.bookname").html(imgstr);
						$("."+thisclass).find("td.price").html(result.price);
					}else{
						$("."+thisclass).find("td.bookname").html("系统未获取到该书数据");
					}
					thisclass--;
				}
			});
			
		})
});

function delsure(kucunid){
	if(kucunid==""){
		layer.msg('参数错误！', {icon: 2});return;
	}
	layer.confirm('是否确认删除该信息？', {
		icon: 3,
		btn: ['确认','取消'] //按钮
	}, function(){
		var url = "{:U('index/delbook')}&kucunid="+kucunid;
		window.location.href=url;
	});
}


$("#printlist").click(function(){
	var query = "<?php $s = $_SERVER['QUERY_STRING'];$s = str_replace("m=index&a=printlist",'',$s);echo $s; ?>";
	var url = "{:U('index/printlistsure')}&query="+query;
	var fulls = "left=0,screenX=0,top=0,screenY=0,scrollbars=1";    //定义弹出窗口的参数  
	if (window.screen) {  
		var ah = screen.availHeight - 30;  
		var aw = screen.availWidth - 10;  
		fulls += ",height=" + ah;  
		fulls += ",innerHeight=" + ah;  
		fulls += ",width=" + aw;  
		fulls += ",innerWidth=" + aw;  
		fulls += ",resizable"  
	} else {  
		fulls += ",resizable"; // 对于不支持screen属性的浏览器，可以手工进行最大化。 manually  
	}
	window.open(url,'',fulls);  
	
	layer.confirm('是否已经完成打印？确认后将把状态置为已打印!', {
		icon: 3,
		btn: ['确认','取消'] //按钮
	}, function(){
		//var url = "{:U('index/delbook')}&kucunid=";
		var url = "{:U('index/printend')}";
		window.location.href=url;
	});
})
</script>
</html>
